﻿@{
    Layout = null;
    DeliveryManage.Models.ReturnMsgModel returnMsg = ViewBag.ReturnMsgModel;
    Dictionary<int, string> dicDeliveryWay = ViewData["dicDeliveryWay"] as Dictionary<int, string>;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>团队业绩</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" href="~/Content/font.css">
    <link rel="stylesheet" href="~/Content/framemain.css">
    <link rel="stylesheet" href="~/Content/pagination.css" />
    <script type="text/javascript" src="~/Content/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="~/Scripts/common.js"></script>
    <script type="text/javascript" src="~/Scripts/framemain.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <link href="~/Scripts/datepicker/skin/WdatePicker.css" rel="stylesheet" />
    <script src="~/Scripts/datepicker/WdatePicker.js"></script>
    <script src="~/Scripts/datepicker/date-content.js"></script>
    <style>
        .layui-table img {
            max-width: inherit;
        }

        .pro-img {
            border-radius: 5px;
            border: 1px solid #f2f2f2;
        }
    </style>
</head>
<body>
    @using (Html.BeginForm("TeamPerformance", "Data", FormMethod.Get))
    {
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="javascript:;">首页</a>
                <a><cite>团队业绩</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        if (returnMsg.code == 200)
        {
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card layui-form">
                            <div class="layui-card-header">
                                <div class="layui-inline layui-show-xs-block">员工类型:</div>
                                <div class="layui-inline layui-show-xs-block" style="width:100px;">
                                    @Html.DropDownList("totype", ViewData["ToTypeList"] as SelectList, new { @class = "layui-input layui-select", id = "datetype", @lay_filter = "datetype" })
                                </div>
                                <div class="layui-inline layui-show-xs-block">查询区间:</div>
                                <div class="layui-inline layui-show-xs-block">→</div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input placeholder="开始日" name="startdate" id="startdate" class="layui-input rule-date-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:minusOneDay($('#enddate').val())})" value="@ViewData["Startdate"]" />
                                </div>
                                <span>-</span>
                                <div class="layui-inline layui-show-xs-block">
                                    <input placeholder="截止日" name="enddate" id="enddate" class="layui-input rule-date-input" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate:addOneDay($('#startdate').val()) })" value="@ViewData["Enddate"]" />
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="hidden" name="uid" id="uid" value="@ViewData["SelectUser"]" />
                                    <input type="hidden" name="pageSize" id="pageSize" value="@ViewData["pageSize"]" />
                                    <input type="hidden" name="page" id="page" value="@ViewData["page"]" />
                                </div>
                                <div class="layui-inline layui-show-xs-block" style="float:right">
                                    <input type="submit" value="&#xe615; 查询" class="layui-btn layui-btn-select layui-icon" />
                                    <input type="button" value="&#xe67d; 导出业绩报表" class="layui-btn layui-btn-normal layui-icon" onclick="BtnExportSourse()">
                                    <a href="#" id="xiazai"></a>
                                </div>
                            </div>
                            <div class="layui-card-body ">
                                <table class="layui-table layui-form">
                                    <thead>
                                        <tr>
                                            <th>员工名称</th>
                                            <th>员工类型</th>
                                            <th>总业绩（元）</th>
                                            <th>提成金额（元）</th>
                                            <th>总单量（个）</th>
                                            @*<th>套餐总金额（元）</th>
                                            <th>套餐加价总额（元）</th>
                                            <th>运费加价总额（元）</th>*@
                                            <th>新单（个）</th>
                                            <th>复购单（个）</th>
                                            <th>送酒次数(次)</th>
                                            <th>新单业绩（元）</th>
                                            <th>复购单业绩（元）</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            if (ViewBag.PerformanceList.Count > 0)
                                            {
                                                foreach (DeliveryManage.Models.EmployeePerformance item in ViewBag.PerformanceList)
                                                {
                                                    <tr>
                                                        <td>
                                                            <a title="查看下级员工业绩" onclick="parent.xadmin.add_tab('@item.EmployeeName 下级员工业绩情况','/Data/TeamPerformance?uid=@item.Employee')" href="javascript:;" style="text-decoration:underline; color:#666"><i class="layui-icon">&#xe615;</i> @item.EmployeeName</a>
                                                        </td>
                                                        <td>@(item.EmployeeType?"有底薪":"无底薪")</td>
                                                        <td>@item.TotalFinalAmount.ToString("F2")</td>
                                                        <td>@item.MyPerformanceAmount.ToString("F2")</td>
                                                        <td>@item.AddOrderNum</td>
                                                        @*<td>@item.TotalGoodsAmount </td>
                                                        <td>@item.TotalAddPrice </td>
                                                        <td>@item.TotalFreight</td>*@
                                                        <td>@item.NewOrderNum</td>
                                                        <td>@item.RepurchaseOrder</td>
                                                        <td>@item.GiftFrequency</td>
                                                        <td>@item.NewOrderAmount.ToString("F2")</td>
                                                        <td>@item.RepurchaseOrderAmount.ToString("F2")</td>
                                                    </tr>
                                                }
                                            }
                                            else
                                            {
                                                <tr>
                                                    <td colspan="9" align="center" height="200"><img src="~/images/nodata.png" style=" width: 10%; " /><br /> 暂无相关数据</td>
                                                </tr>
                                            }
                                        }

                                    </tbody>
                                </table>
                            </div>

                            <div class="pagelist">
                                <div id="PageContent" class="default">@Html.Raw(ViewBag.PageInnerHtml)</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        }
    }

    <script type="text/javascript">
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        //切换分页大小
        form.on('select(selectpage)', function (data) {
            var data = thisdata();//搜索条件
            locations(data);
        })
    });

    //搜索参数函数
    function thisdata()
    {
        var data = {
            pageCount: $('.txtPageCount').val(),
            pageSize: $("select[name=select_page").val(), 
            totype: $('#totype').val(),
            uid: $('#uid').val(),
        };

        if (data.pageCount=="") {
            data.pageCount= @ViewData["page"];
        }
        return data;
    }

    //调用页面方法
    function locations(data) {
        window.location.href = '/Data/TeamPerformance?page=' + data.pageCount + "&pageSize=" + data.pageSize + "&uid=" + data.uid + '&totype=' + data.totype + '&startdate=' + data.startdate + '&enddate=' + data.enddate;
    }

        //导出
    function BtnExportSourse() {
        var data = thisdata();//搜索条件
        layer.confirm('确认导出业绩报表吗?', { icon: 3, title: '提示' }, function (index) {
            $.ajax({
                type: "POST",
                url: "/Data/ExportTeamPerformance",
                data: data,
                success: function (data) {
                    if (data.status == true) {
                        layer.msg(data.msg, { icon: 6, title: '提示' }, function (index) {
                            var filepath = "http://" + data.data;
                            $("#xiazai").attr("href", filepath);
                            document.getElementById("xiazai").click();
                            layer.close();
                        })
                    } else {
                        layer.msg(data.msg, { icon: 5, title: '提示' }, function (index) {
                            layer.close();
                        })
                    }
                }
            })
            layer.close();
        })
    }

    $(function () {
          //操作提示
          if (@returnMsg.code == 400) {
              layer.msg('@returnMsg.msg', { icon: 5, title: '提示' }, function (index) {
                layer.close();
              })
          }

          //跳转页
          $("#locationPageBtn").click(function () {
              var data = thisdata();//搜索条件
              locations(data);
          });
      })
    </script>
</body>
</html>
